package com.cc.main.problems.bean;

import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;

import com.cc.main.ICommonCmd;

/**
 * 命令参数集
 * @author TR
 *
 */
public class CmdBean {
	public ICommonCmd cls;
	public String keyCmdDescrips = "";//问题描述
	public List<KeyWordItem> defaultKeyList = new ArrayList<>();//问题关键字
	
	public CmdBean(ICommonCmd c,String kcd) {
		cls = c;
		keyCmdDescrips = kcd;
	}
	
	public CmdBean(Class c,String kcd) {
		cls = instance(c);
		keyCmdDescrips = kcd;
	}

	public void addKeyWord(String key,boolean show) {
		defaultKeyList.add(new KeyWordItem(key,show));
	}
	public void addKeyWord(String key) {
		defaultKeyList.add(new KeyWordItem(key));
	}
	
	private ICommonCmd instance(Class cls) {
		try {
			return (ICommonCmd) cls.getConstructor().newInstance();
		} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException
				| NoSuchMethodException | SecurityException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}
}
